﻿using Sasc.PV.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

namespace Sasc.PV.Web
{
    public static class DataBinderHelper
    {
        public static T Eval<T>(object container, string expression, T defaultValue = default(T))
        {
            var obj = DataBinder.Eval(container, expression);
            try
            {
                return ConvertHelper.ChangeType<T>(obj);
            }
            catch (Exception e)
            { 
            }
            return defaultValue;
        }

        public static string Eval(object container, string expression, string format)
        {
            return DataBinder.Eval(container, expression, format);
        }
    }
}